package net.aaa.hotel.controller;

import com.alibaba.fastjson.JSON;
import net.aaa.hotel.dao.UserDao;
import net.aaa.hotel.dao.impl.UserDaoImpl;
import net.aaa.hotel.entity.Custom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 凉凉
 * @time
 */

@RestController
@RequestMapping("/User")
public class UserFController {

    @Autowired
    private UserDao userDao=new UserDaoImpl();


    @RequestMapping("index")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("qianduan/index.jsp");
        return modelAndView;
    }

    @RequestMapping("/queryAll")
    public Map queryAll(HttpServletRequest req, HttpServletResponse resp, HttpSession session) throws ServletException, IOException {
        Map cuser = (Map) session.getAttribute("cuser");
        //cuser{idcard=123, name=123, id=8, pwd=1312, iphone=123, status=0}
      //  System.out.println("cuser"+cuser.get("id"));
        List<Map> query= userDao.query(cuser);
        return query.get(0);
    }
    @RequestMapping("/update")
    public String update(Custom xinxi){
        System.out.println("xinxi1111"+xinxi);
        System.out.println(xinxi.getId());
        int update1 = userDao.update(xinxi);
      return "1";
    }


}
